package ru.ifmo.ctddev.larionov.task2;

import java.util.Iterator;

public class Main {

	public static void main(String[] args) {

		LinkedBag<Integer> a = new LinkedBag<Integer>();
		a.add(5);
		Iterator<Integer> it = a.iterator();
		it.next();
		a.add(3);
		a.add(3);
		a.add(1);
		it = a.reverseIterator();
		it.next();
		it.next();
		it.remove();
		it = a.iterator();
		a.remove(1);
		System.out.println(a.size());
		while (it.hasNext())
			System.out.print(it.next() + " ");
	}

}